package com.dyz.leetcode;

public class ProductExceptSelf238 {
    public int[] productExceptSelf(int[] nums) {
        int [] dp = new int[nums.length];
        int l=1, r=1;
        for (int i=0; i<nums.length;i++){
            dp[i]=l;
            l=l*nums[i];
        }

        for(int j=nums.length-1; j>=0; j--){
            dp[j]=dp[j]*r;
            r*=nums[j];
        }
        return dp;
    }
}
